package com.zhengqing.softdemo

/*
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class SoftDemoApplication

// Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
// 注意： 如果您当前使用的是 SpringBoot v3.x 版本，需要把依赖 mybatis-flex-spring-boot-starter
// 修改为：mybatis-flex-spring-boot3-starter
fun main(args: Array<String>) {
	runApplication<SoftDemoApplication>(*args)
}*/

import org.springframework.boot.runApplication
// import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.core.env.Environment
import java.net.InetAddress

@SpringBootApplication
class SoftDemoApplication

fun main(args: Array<String>) {
	val application = runApplication<SoftDemoApplication>(*args)
	val env: Environment = application.environment
	val ip = InetAddress.getLocalHost().hostAddress
	val port = env.getProperty("server.port")
	val property = env.getProperty("server.servlet.context-path")
	val path = property ?: ""
	println(
			"\n\t" +
					"----------------------------------------------------------\n\t" +
					"Application Spring-Boot is running! Access URLs:\n\t" +
					"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
					"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
					"------------------------------------------------------------")
}

/*
// 转换的版本时报错的
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.core.env.Environment
import java.net.InetAddress



// org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: @Configuration class 'SoftDemoApplication' may not be final. Remove the final modifier to continue.
//Offending resource: com.zhengqing.softdemo.SoftDemoApplication

// import org.mybatis.spring.annotation.MapperScan;
// import springfox.documentation.swagger2.annotations.EnableSwagger2;
// @EnableSwagger2 // swagger UI 查看接口用
@SpringBootApplication // @MapperScan("com.example.demo.mapper") // // 配置类里有就可以了,两处都写也没问题不报错
object SoftDemoApplication { // 不能用class 报错
    @Throws(Exception::class)
    @JvmStatic
    fun main(args: Array<String>) {
        // SpringApplication.run(JavaLearningApplication.class, args);
        val application = SpringApplication.run(SoftDemoApplication::class.java, *args)
        val env: Environment = application.environment
        val ip = InetAddress.getLocalHost().hostAddress
        val port = env.getProperty("server.port")
        val property = env.getProperty("server.servlet.context-path")
        val path = property ?: ""
        println(
                "\n\t" +
                        "----------------------------------------------------------\n\t" +
                        "Application Spring-Boot is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                        "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                        "------------------------------------------------------------")
    }
}
*/
